package com.mall.mapper;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.mall.entity.OrderItem;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

/**
 * @author ShouPeng
 * @since 2024-01-17
 * 订单中的商品mapper
 */
@Repository
@Mapper
public interface OrderItemMapper extends BaseMapper<OrderItem> {


    /**
     * 查询订单包含的商品
     * @return list
     */
    @Select("select mg.goods_id as goodsId,quantity,goods_cover as goodsCover,goods_name as goodsName,goods_price as goodsPrice " +
            "from mall_order_item moi left join mall_goods mg on moi.goods_id = mg.goods_id where moi.order_id = #{orderId}")
    List<Map<String,Object>> queryOrderItemById(Integer orderId);

}
